import time
import subprocess

process = subprocess.Popen("./test.sh", shell=True, start_new_session=True)
print("pid:", process.pid)

while True:
    print("主进程运行中")
    time.sleep(1)
    
""" 运行结果:
主进程 ctrl +c 退出,
./test.sh 依然在后台运行

"""